{% extends "base.html" %}

{% block content %}
<div class="container">
    <form method="GET" action="{{ url_for('report_annual_emission.index') }}">
        <div class="row mb-3">
            <div class="col-md-3">
                <label for="year" class="form-label">选择年份</label>
                <select class="form-select" id="year" name="year">
                    <option value="2023" {% if selected_year == 2023 %}selected{% endif %}>2023</option>
                    <option value="2024" {% if selected_year == 2024 %}selected{% endif %}>2024</option>
                    <option value="2025" {% if selected_year == 2025 %}selected{% endif %}>2025</option>
                </select>
            </div>
            <div class="col-md-2 align-self-end">
                <button type="submit" class="btn btn-primary">汇总</button>
            </div>
        </div>
    </form>
    

    
    {% if report_data %}
    <h2>报告主体{{ report_data.year }}年温室气体排放量汇总表</h2>
    <div class="mb-3">
        <div class="btn-group">
            <a href="{{ url_for('report_annual_emission.export', format='excel', year=selected_year) }}" class="btn btn-success">导出Excel</a>
            <a href="{{ url_for('report_annual_emission.export', format='word', year=selected_year) }}" class="btn btn-primary">导出Word</a>
            <a href="{{ url_for('report_annual_emission.export', format='pdf', year=selected_year) }}" class="btn btn-danger">导出PDF</a>
        </div>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>源类别</th>
                <th>排放量(t)</th>
                <th>排放量(tCO2e)</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>化石燃料燃烧CO2排放</td>
                <td>{{ report_data.fossil_fuel_t|default('None') }}</td>
                <td>{{ report_data.fossil_fuel_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>CO2过程排放</td>
                <td>{{ report_data.process_co2_t|default('None') }}</td>
                <td>{{ report_data.process_co2_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>HFCs过程排放</td>
                <td>{{ report_data.process_hfcs_t|default('None') }}</td>
                <td>{{ report_data.process_hfcs_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>PFCs过程排放</td>
                <td>{{ report_data.process_pfcs_t|default('None') }}</td>
                <td>{{ report_data.process_pfcs_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>SF6过程排放</td>
                <td>{{ report_data.process_sf6_t|default('None') }}</td>
                <td>{{ report_data.process_sf6_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>购入电力产生的排放量</td>
                <td>{{ report_data.purchased_electricity_t|default('None') }}</td>
                <td>{{ report_data.purchased_electricity_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>购入热力产生的排放量</td>
                <td>{{ report_data.purchased_heat_t|default('None') }}</td>
                <td>{{ report_data.purchased_heat_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>输出电力产生的排放量</td>
                <td>{{ report_data.exported_electricity_t|default('None') }}</td>
                <td>{{ report_data.exported_electricity_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>输出热力产生的排放量</td>
                <td>{{ report_data.exported_heat_t|default('None') }}</td>
                <td>{{ report_data.exported_heat_tco2e|default('None') }}</td>
            </tr>
            <tr>
                <td>企业温室气体排放总量(不包括购入和输出的电力、热力)</td>
                <td>{{ report_data.total_without_energy_t|default('None') }}</td>
                <td>{{ report_data.total_emission_exclude_energy_tco2e|round(2)|default('0.00') }}</td>
            </tr>
            <tr>
                <td>企业温室气体排放总量(包括购入和输出的电力、热力)</td>
                <td>{{ report_data.total_with_energy_t|default('None') }}</td>
                <td>{{ report_data.total_emission_include_energy_tco2e|round(2)|default('0.00') }}</td>
            </tr>
        </tbody>
    </table>
    {% endif %}
</div>


{% endblock %}
